@using Volo.Abp.Localization
@using Microsoft.AspNetCore.Mvc.Localization
@using System.Globalization
@inject IHtmlLocalizer<AuthServerLocalResource> Localizer
@inject ILanguageProvider _languageProvider
@{
    var languages = await _languageProvider.GetLanguagesAsync();

    var currentLanguage = languages.FindByCulture(
        CultureInfo.CurrentCulture.Name
    ) ?? languages.FindByCulture(
        CultureInfo.CurrentCulture.Parent.Name
    );

    var returnUrl = string.IsNullOrEmpty(Context.Request.Path) ? "~/" : $"~{Context.Request.Path.Value}";
}
@if (languages.Count > 1)
{
    <div class="dropdown">
        <a class="nav-link dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
            @currentLanguage.DisplayName
        </a>

        <div class="dropdown-menu dropdown-menu-right border-0 shadow-sm" aria-labelledby="dropdownMenuLink">
            @foreach (var language in languages)
            {
                <a class="dropdown-item" href="/Abp/Languages/Switch?culture=@(language.CultureName)&uiCulture=@(language.UiCultureName)&returnUrl=@returnUrl">@language.DisplayName</a>
            }
        </div>
    </div>
}